package ph.com.gs3.formalistics.presenter;

import ph.com.gs3.formalistics.R;
import ph.com.gs3.formalistics.presenter.fragments.views.DeveloperOptionsViewFragment;
import ph.com.gs3.formalistics.presenter.fragments.views.DeveloperOptionsViewFragment.DeveloperOptionsViewActionListener;
import ph.com.gs3.formalistics.presenter.fragments.workers.DeveloperOptionsWorkerFragment;
import android.app.Activity;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.widget.Toast;

public class DeveloperOptionsActivity extends Activity implements
        DeveloperOptionsViewActionListener {

	public static final String TAG = DeveloperOptionsActivity.class.getSimpleName();

	private DeveloperOptionsViewFragment viewFragment;
	private DeveloperOptionsWorkerFragment workerFragment;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_developer_options);

		if (savedInstanceState == null) {
			viewFragment = new DeveloperOptionsViewFragment();
			workerFragment = new DeveloperOptionsWorkerFragment();

			FragmentTransaction transaction = getFragmentManager().beginTransaction();

			transaction.add(R.id.container, viewFragment);
			transaction.add(workerFragment, DeveloperOptionsViewFragment.TAG);

			transaction.commit();
		}
	}

	// ========================================================================
	// {{ View Implementation Methods

	@Override
	public void onResetDatabaseCommand() {
		workerFragment.resetDatabase();

		Toast.makeText(this, "Database reset, close this application and open again.",
		        Toast.LENGTH_LONG).show();
	}

	@Override
	public void onTestCommModuleCommand() {
		workerFragment.testCommentCommModule();
	}

	// }}

}
